package com.game.gameshoppingcenter.controller;

import com.game.gameshoppingcenter.entities.Comment;
import com.game.gameshoppingcenter.entities.Orders;
import com.game.gameshoppingcenter.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("/Comment")
public class CommentController {
    @Autowired
    CommentService commentService;
    @RequestMapping("/save")
    public String save(Comment comment, Model model){
        model.addAttribute("comments",comment);
        commentService.save(comment);
        return"/Century：Age of Ashes";

    }
    @RequestMapping("/save1")
    public String save1(Comment comment, Model model){

       model.addAttribute("comment1",comment);
        commentService.save(comment);

        return"/Age of Empires IV";

    }

    @RequestMapping("/save2")
    public String save2(Comment comment, Model model){
        model.addAttribute("comment2",comment);
        commentService.save(comment);
        return"/Chinese Paladin 7";

    }
    @RequestMapping("/save3")
    public String save3(Comment comment, Model model){
        model.addAttribute("comment3",comment);
        commentService.save(comment);
        return"/CSGO";

    }
    @RequestMapping("/save4")
    public String save4(Comment comment, Model model){
        model.addAttribute("comment4",comment);
        commentService.save(comment);
        return"/Fight";

    }
    @RequestMapping("/save5")
    public String save5(Comment comment, Model model){
        model.addAttribute("comment5",comment);
        commentService.save(comment);
        return"/Destiny 2";

    }
    @RequestMapping("/getcontent")
    public String togetcontent(Comment comment, Model model){

        model.addAttribute("comment6",comment);
        commentService.save(comment);

        return"/Age of Empires IV";

    }
@RequestMapping("/toComments")
    //把数据库订单信息渲染到订单页面中
    public String toComments( Model model){
        List<Comment> commentList=commentService.getcomment();
        model.addAttribute("commentList",commentList);
        System.out.println(commentList);
        return "/Comments";

    }



}
